package kyssion.leetcode.num201_250;

import java.util.ArrayList;
import java.util.List;

public class code232_用栈实现队列 {
    class MyQueue {

        List<Integer> item;
        int index;

        /**
         * Initialize your data structure here.
         */
        public MyQueue() {
            item = new ArrayList<>();
        }

        /**
         * Push element x to the back of queue.
         */
        public void push(int x) {
            item.add(x);
        }

        /**
         * Removes the element from in front of queue and returns that element.
         */
        public int pop() {
            return item.get(index++);
        }

        /**
         * Get the front element.
         */
        public int peek() {
            return item.get(index);
        }

        /**
         * Returns whether the queue is empty.
         */
        public boolean empty() {
            return index == item.size();
        }
    }
}
